/**
 * Created by Administrator on 2017/7/19.
 */
//测试
var verBaseUrl = "http://f1707n6052.51mypc.cn/CardOilServer/";
//var verBaseUrl = "http://wx.yuandongsenlin.com/CardOilServer/";
//var verBaseUrl = "http://apps.yktcards.com:8086/CardOilServer/";
var activityId  = "851f34ce46af452a817da96c5c8c4708";
//生产mrchIds
//var mrchIds='981000912';
//测试mrchIds
var mechIds='201705269680677';
//正式
//var verBaseUrl = "http://xapps.yktcards.com/CardOilServer/";
$(function () {
    var u = navigator.userAgent,
        app = navigator.appVersion;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
    var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if (isAndroid) {
        var daa = document.getElementsByClassName('head');
        daa[0].style.display = "block";
    }
    if (isIOS) {
        var daa = document.getElementsByClassName('head');
        daa[0].style.display = "none";
      /*  var isPageHide = false;
        window.addEventListener('pageshow', function () {
            if (isPageHide) {
                window.location.reload();
            }
        });
        window.addEventListener('pagehide', function(){
            isPageHide = true;
        });*/
    }
});
var obj = new Object();
obj.url = window.location.href;
/*setTimeout(function () {
   // wxJsSdkInit()
}, 200);*/
var wxConfig = false;
function wxJsSdkInit() {
    $.ajax({
        type: "post",
        url: "/CardOilServer/wechat/sdkInit",
        data: obj,
        beforeSend: function () {
            load.loading = true;
        },
        success: function (data) {
            load.loading = false;
            wx.config({
                debug: false,
                appId: data.appid,
                timestamp: data.timestamp,
                nonceStr: data.nonceStr,
                signature: data.signature,
                jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage']
            });
            wx.ready(function () {
                wxConfig = true;
                wx.onMenuShareTimeline({
                    title: '用海贝，享95折加油！手机充值更便捷，支付优惠天天有！', // 分享标题
                    link: verBaseUrl + "wechat/index",
                    imgUrl: verBaseUrl + 'images/card-logo.png', // 分享图标
                    success: function () {
                        // 用户确认分享后执行的回调函数

                    },
                    cancel: function () {
                        // 用户取消分享后执行的回调函数
                    }
                });
                wx.onMenuShareAppMessage({
                    title: '用海贝享95折加油，手机充值更便捷', // 分享标题
                    desc: '支付还有优惠抢哦！最高立减8元', // 分享描述
                    link: verBaseUrl + "wechat/index", // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                    imgUrl: verBaseUrl + 'images/card-logo.png', // 分享图标
                    type: '', // 分享类型,music、video或link，不填默认为link
                    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                    success: function () {
                        // 用户确认分享后执行的回调函数
                    },
                    cancel: function () {
                        // 用户取消分享后执行的回调函数
                    }
                });
            });
            // layer.msg(data.result.swift_number);
        },
        error: function () {
            layer.msg("服务异常");
            load.loading = false;
        }
    });
}